package com.cqc.other.juc.volatil.demo3;


import java.util.concurrent.TimeUnit;


public class VolatileTest {

    public static void main(String[] args) throws InterruptedException {
        DataEntity dataEntity = new DataEntity();
        AThread aThread = new AThread(dataEntity);
        aThread.start();
        BThread bThread = new BThread(dataEntity);
        bThread.start();

        TimeUnit.SECONDS.sleep(2);
        System.out.println(dataEntity.getCount());
        /**
         * volatile 不适用的场景方法2：  lock.lock()
         */
    }
}
